#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmp_int(const void* x,const void* y)
{
	return *(int*)x - *(int*)y;
}
typedef struct stu
{
	char name[20];
	int age;
}s;
int cmp_sa(const void* x, const void* y)
{
	return ((s*)x)->age - ((s*)y)->age;
}
int cmp_sn(const void* x, const void* y)
{
	return strcmp(((s*)x)->name , ((s*)y)->name);
}
int main()
{
	int a[] = { 5,2,3,8,7,6,0,2,9 };
	int a_sz = sizeof(a) / sizeof(a[0]);
	qsort(a,a_sz , sizeof(int), cmp_int);
	for (int i = 0; i < a_sz; i++)
		printf("%d ", a[i]);
	printf("\n");
	printf("======================================\n");
	s b[3] = { {"zhangsan",10}, {"lisi",20}, {"wangwu",30}};
	int b_sz = sizeof(b)/sizeof(b[0]);
	qsort(b, b_sz, sizeof(b[0]), cmp_sa);
	for (int i = 0; i < b_sz; i++)
		printf("%s:%d\n",b[i].name, b[i].age);
	printf("\n");
	printf("======================================\n");
	qsort(b, b_sz, sizeof(b[0]), cmp_sn);
	for (int i = 0; i < b_sz; i++)
		printf("%s:%d\n", b[i].name, b[i].age);
	return 0;
}